<script src="jscript/popup.js" type="text/javascript"></script>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">

	function init() {
		oEditor = FCKeditorAPI.GetInstance('body');
		ShowHideRoles();
	}
	
	function insertLink(field, value_id, value_name) {
		
		ids = value_id.toString().split(',');
		if(ids[1]) {
			l = "[link:"+field+"|"+ids[0]+"|"+ids[1]+"]";
		} else {
			l = "[link:"+field+"|"+ids[0]+"]";
		}
		
/*
		alert(oEditor.Selection);
		var sSelected; 
		if ( oEditor.FCKBrowserInfo.IsGecko ) { 
		sSelected = FCK.EditorWindow.getSelection(); 
		} else { 
		sSelected = FCK.EditorDocument.selection.createRange().text; 
		} 
*/
		
		
		oEditor.CreateLink(l);
	}
	
	function ShowHideRoles() {
		var obj = document.getElementById("private");
		if(obj) {
			var val = (obj.checked == true);
			ShowHideDiv('roles_div', val, true);
		}
	}
	
	function xajax_getCategoryRoles() {
		return true;
	}
	
	function ShowHideMeta() {
		var obj = document.getElementById('meta_div');
		var val = (obj.style.display == 'none');
		ShowHideDiv('meta_div', val, true);
	}

	function categoryAjaxHandler(category_id) {
		xajax_getCategoryRoles(category_id);
		xajax_populateSelect(category_id);
	}
	
	window.onload = init;
	
</SCRIPT>
{xajax_js}

{error_msg}

<!-- onSubmit="return Validate(this);" -->
<form action="{action_link}" method="post" name="" id="">
{hidden_fields}

<table border=0 width="100%" cellpadding="5" cellspacing="1">
<tr>
	<td colspan="2" class="tdTitle"><b>{action_title}</b></td>
</tr>

<!-- <tr class="trlighter">
	<td class="tdFormCaption" nowrap valign="top">{category_msg}: {required_sign}</td>
	<td>
		<table cellpadding="0" cellspacing="0">
		<tr>
			<td>
				<select name="category[]" id="category" size="6" multiple style="width: 300px;" 
					onChange="xajax_getCategoryRoles(this.value)">
				{category_select}
				</select>
			</td>
			<td>&nbsp;&nbsp;</td>
			<td valign="top">
				<div id="category_info">{category_info}</div>
			</td>
		</tr>
		</table>
	</td>
</tr> -->

<tr class="trlighter">
	<td class="tdFormCaption" nowrap valign="top">{category_msg}: {required_sign}</td>
	<td>
		<table cellpadding="0" cellspacing="0">
		<tr>
			<td>
				<div style="padding-bottom: 4px;">{category_msg}:</div>
				<select name="category[]" id="category" size="6" style="width: 300px;" 
					onChange="categoryAjaxHandler(this.value);">
				{category_select}
				</select>
			</td>
			<td style="padding: 15px;"></td>
			<td valign="top">
				<div style="padding-bottom: 4px;">{mirror_in_category_msg}:</div>
				<select name="category_mirror[]" id="category_mirror" size="6" multiple style="width: 300px;">
				{category_mirror_select}
				</select>				
			</td>
		</tr>
		</table>
	</td>
</tr>

<tr class="trlighter">
	<td class="tdFormCaption" nowrap valign="top">{entry_title_msg}: {required_sign}</td>
	<td>
		<tmpl:member_question>
			<textarea cols="" rows="4" name="title" id="title" style="width: 100%">{title}</textarea>
		</tmpl:member_question>
		<tmpl:question>
			<textarea cols="" rows="2" name="title" id="title" style="width: 100%">{title}</textarea>
		</tmpl:question>		
	</td>
</tr>

<tr class="trlighter">
	<td class="tdFormCaption" nowrap valign="top">
		{entry_body_msg}: {required_sign}
		<!-- <a href="" onclick="oEditor.InsertHtml('15'); return false;">hgjhgj</a> -->
	</td>
	<td>{vck_editor}</td>
</tr>

<!-- <tr class="trlighter">
	<td class="tdFormCaption" nowrap valign="top">
		{meta_info_msg}:
	</td>
	<td>
		<a href="javascript:ShowHideMeta(); void(0);"><b>Hide/Show</b></a>
		<div id="meta_div" style="display: none">
			<br>
			<div style="padding-bottom: 3px;">{meta_keywords_msg}:</div>
			<input type="text" name="meta_keywords" value="{meta_keywords}" style="width: 100%;">
			<br><br>
			<div style="padding-bottom: 3px;">{meta_description_msg}:</div>
			<textarea cols="80" rows="2" name="meta_description" style="width: 100%;">{meta_description}</textarea>
		</div>
		
	</td>
</tr> -->

<tr class="trlighter">
	<td class="tdFormCaption" nowrap valign="top">{meta_keywords_msg}:</td>
	<td>
		<input type="text" name="meta_keywords" value="{meta_keywords}" style="width: 100%;">
	</td>
</tr>

<tr class="trlighter">
	<td class="tdFormCaption" nowrap valign="top">{meta_description_msg}:</td>
	<td>
		<textarea cols="80" rows="2" name="meta_description" style="width: 100%;">{meta_description}</textarea>
	</td>
</tr>

<!-- <tr class="trlighter">
	<td class="tdFormCaption" nowrap>{sort_order_msg}:</td>
	<td><input type="text" name="sort_order" id="sort_order" value="{sort_order}" style="width: 50px;"></td>
</tr> -->

<tr class="trlighter">
	<td class="tdFormCaption" nowrap>{sort_order_msg}:</td>
	<td>
		<select name="sort_order" id="sort_order" style="width: 100%;">
			{sort_order_select}
		</select>
	</td>
</tr>

<tr class="trlighter" valign="top">
	<td class="tdFormCaption" nowrap>{related_articles_msg}:</td>
	<td>
		<div style="padding-bottom: 3px;">
		<a href="javascript:OpenPopup('index.php?module=knowledgebase&page=kb_entry', 'r', 'r');" title="{add_new_msg}">
			<img src="images/icons/add_new.gif" border="0" alt="{add_new_msg}"></a>
		</div>

		<tmpl:related_row>
			
			<div class="popUpDiv">
				<div style="float: left;">
				<input type="hidden" name="related[]" value="{article_id}"><span>{title}</span>
				</div>
				<div align="right">
				<a id="" href="" onClick="insertLink('article', {article_id}); return false;">{insert_as_link_msg}</a>
				| <a href="" onClick="removeHtml(this, '{sure_common_msg}'); return false;">{delete_msg}</a>
				</div>
			</div>
		
		</tmpl:related_row>
		
		<span id="writeroot_article"></span>
				
	</td>
</tr>

<tr class="trlighter" valign="top">
	<td class="tdFormCaption" nowrap>{attachment_msg}:</td>
	<td>
		<div style="padding-bottom: 3px;">
		<a href="javascript:OpenPopup('index.php?module=file&page=file_entry', 'r', 'r');" title="{add_new_msg}">
			<img src="images/icons/add_new.gif" border="0" alt="{add_new_msg}"></a>
		</div>
		
		<tmpl:attachment_row>
		
			<div class="popUpDiv">
				<div style="float: left;">
				<input type="hidden" name="attachment[]" value="{attachment_id}"><span>{filename}</span>
				</div>
				<div align="right">
				<a href="" onClick="insertLink('file', '{attachment_id}'); return false;">{insert_as_link_msg}</a>
				| <a href="" onClick="removeHtml(this, '{sure_common_msg}'); return false;">{delete_msg}</a>
				</div>
			</div>
		
		</tmpl:attachment_row>
		
		<span id="writeroot"></span>
				
	</td>
</tr>

<tmpl:private>
<tr class="trlighter">
	<td class="tdFormCaption" nowrap valign="top">{private_msg}:</td>
	<td>
		<input type="checkbox" name="private" id="private" value="1" {private_options} onClick="ShowHideRoles()"> {yes_msg}
		<span style="margin-left: 10px;" id="category_info_1">{category_info}</span>
		
		<div id="roles_div" style="display: none">
			<div style="padding: 8px 0px;">{role_access_msg}:&nbsp;&nbsp;
				<a href="javascript:selectAll(true, 'member_role'); void(0);">{all_msg}</a> |
				<a href="javascript:selectAll(false, 'member_role'); void(0);">{none_msg}</a>
			</div>
			
			<select name="member_role[]" id="member_role" size="4" multiple style="WIDTH: 250px">
				{member_role_select}
			</select>
		</div>
		
	</td>
</tr>
</tmpl:private>

<tr class="trlighter">
	<td class="tdFormCaption">{status_msg}:</td>
	<td>{status_checkbox}</td>
</tr>

<tr> 
	<td></td>
	<td><div><br></div>
		<input type="submit" name="submit" value="{ok_msg}" class="button">
		<input type="button" value="{cancel_msg}" onClick="location.href='{cancel_link}'" class="button">
	</td>
</tr>
</table>
</form>

<div id="readroot" style="display: none">
	<div id='d' class="popUpDiv">
		<div style="float: left;">
		<input type="hidden" name="attachment[]" value="" id=""><span>1</span>
		</div>
		<div align="right">
		<a id="" href="" onClick="insertLink('file', this.id); return false;">{insert_as_link_msg}</a>
		| <a href="" onClick="removeHtml(this, '{sure_common_msg}'); return false;">{delete_msg}</a>
		</div>
	</div>
</div>

<div id="readroot_article" style="display: none">
	<div id='d' class="popUpDiv">
		<div style="float: left;">
		<input type="hidden" name="related[]" value=""><span>1</span>
		</div>
		<div align="right">
		<a id="" href="" onClick="insertLink('article', this.id); return false;">{insert_as_link_msg}</a>
		| <a href="" onClick="removeHtml(this, '{sure_common_msg}'); return false;">{delete_msg}</a>
		</div>
	</div>
</div>